package com.exam.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.exam.entity.Exam;
@Repository
public interface ExamRepository extends PagingAndSortingRepository<Exam, Long>, JpaSpecificationExecutor<Exam> {
	@Query(value="from Exam e where e.course.id = ?1 and e.date!=null")
	public List<Exam> findStuExam(Long id);
	@Query(value="from Exam e where e.course.id=?1")
	public List<Exam> findByCourseId(Long id);
	@Query(value="from Exam e where e.paper.id=?1")
	public List<Exam> findByPaperId(Long id);
	@Query(value="from Exam e where e.num=?1")
	public Exam findByNum(String num);
	@Query(value="from Exam e where e.marked=false and e.course.teacher.id=?1")
	public List<Exam> findByTeacherId(Long id);
}
